Use case: DCACHE maintenance operations in polling mode

Sequence diagram

DCACHE maintenance operations in polling mode.

  @startuml
  skinparam sequenceMessageAlign center

  participant "User\nApplication" as UA
  participant "DCACHE\nDriver" as DD

  UA->DD : **HAL_DCACHE_Init**
  DD-->"Driver RCC" : Compilation switch: clock activation
  rnote over DD
  Invalidate Operation by Hardware
  endrnote
  UA <-- DD : return HAL_OK or HAL_INVALID_PARAM
  |||
  group Loop [Can be repeated]

  group Optional
  UA->DD : **HAL_DCACHE_SetReadBurstType**
  DD --> UA : return HAL_OK

  UA->DD : **HAL_DCACHE_Monitor_Start**
  DD --> UA : return HAL_OK
  |||
  end

  UA->DD : **HAL_DCACHE_Enable**
  DD --> UA : return HAL_OK

  group Loop [Can be repeated]

  UA->DD : **HAL_DCACHE_Invalidate**,\n**...**\n**HAL_DCACHE_CleanByAddr**,\n**...**\n**HAL_DCACHE_InvalidateByAddr**,\n**...**\n**HAL_DCACHE_CleanInvalidByAddr**,\n**...**
  DD --> UA : return HAL_OK, HAL_BUSY, HAL_ERROR
  |||
  end

  group Optional
  UA->DD : **HAL_DCACHE_Monitor_GetReadHitValue**, **HAL_DCACHE_Monitor_GetReadMissValue**,\n**HAL_DCACHE_Monitor_GetWriteHitValue**, **HAL_DCACHE_Monitor_GetWriteMissValue**
  DD --> UA : Monitor's value

  UA->DD : **HAL_DCACHE_Monitor_Reset**
  DD --> UA : return HAL_OK

  end
  |||
  UA->DD : **HAL_DCACHE_Disable**
  DD --> UA : return HAL_OK
  |||
  end
  |||
  UA->DD : **HAL_DCACHE_DeInit**
  DD --> UA

  @enduml

Code snippet

HAL1

HAL2

/* Init */
HAL_DCACHE_Init(&hdcache);

/* Optional configuration */
HAL_DCACHE_SetReadBurstType(&hdcache, HAL_DCACHE_READ_BURST_WRAP);
HAL_DCACHE_Monitor_Start(&hdcache);

/* Enable DCACHE */
HAL_DCACHE_Enable(&hdcache);

/* Maintenance operations (repeat as needed) */
HAL_DCACHE_Invalidate(&hdcache);
HAL_DCACHE_CleanByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
HAL_DCACHE_InvalidateByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
HAL_DCACHE_CleanInvalidByAddr(&hdcache, (uint32_t *)buffer, buffer_size);

/* Optional monitoring */
(void)HAL_DCACHE_Monitor_GetReadHitValue(&hdcache);
(void)HAL_DCACHE_Monitor_GetReadMissValue(&hdcache);
(void)HAL_DCACHE_Monitor_GetWriteHitValue(&hdcache);
(void)HAL_DCACHE_Monitor_GetWriteMissValue(&hdcache);
HAL_DCACHE_Monitor_Reset(&hdcache);

/* Stop DCACHE */
HAL_DCACHE_Disable(&hdcache);
HAL_DCACHE_DeInit(&hdcache);
/* Init */
HAL_DCACHE_Init(&hdcache);

/* Optional configuration */
HAL_DCACHE_SetReadBurstType(&hdcache, HAL_DCACHE_READ_BURST_WRAP);
HAL_DCACHE_ECC_Enable(&hdcache);
HAL_DCACHE_EnableMonitors(&hdcache);

/* Start DCACHE (no interrupt) */
HAL_DCACHE_Start(&hdcache, HAL_DCACHE_IT_NONE);

/* Maintenance operations (repeat as needed) */
HAL_DCACHE_Invalidate(&hdcache);
HAL_DCACHE_CleanByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
HAL_DCACHE_InvalidateByAddr(&hdcache, (uint32_t *)buffer, buffer_size);
HAL_DCACHE_CleanInvalidByAddr(&hdcache, (uint32_t *)buffer, buffer_size);

/* Optional monitoring */
(void)HAL_DCACHE_GetMonitorReadHitValue(&hdcache);
(void)HAL_DCACHE_GetMonitorReadMissValue(&hdcache);
(void)HAL_DCACHE_GetMonitorWriteHitValue(&hdcache);
(void)HAL_DCACHE_GetMonitorWriteMissValue(&hdcache);
HAL_DCACHE_ResetMonitors(&hdcache);
HAL_DCACHE_ECC_Disable(&hdcache);

/* Stop DCACHE */
HAL_DCACHE_Stop(&hdcache);
HAL_DCACHE_DeInit(&hdcache);

Key changes

  1. HAL2 uses HAL_DCACHE_Start() / HAL_DCACHE_Stop() instead of HAL_DCACHE_Enable() / HAL_DCACHE_Disable().

  2. HAL2 adds optional ECC control and monitor configuration APIs.

  3. HAL2 monitor getter and reset APIs are renamed compared to HAL1.